<?php

/**

 * Used to display pop-up notices to users

 *

 * Used to display helpful messages to users, that can be

 * never shown again.

 *

 * Copyright (C) 2008  Sean Hickey

 * 

 * This program is free software: you can redistribute it and/or modify

 * it under the terms of the GNU General Public License as published by

 * the Free Software Foundation, either version 3 of the License, or

 * (at your option) any later version.

 *

 * This program is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

 * GNU General Public License for more details.

 *

 * You should have received a copy of the GNU General Public License

 * along with this program.  If not, see <http://www.gnu.org/licenses/>.

 *

 * @author Sean Hickey <sean@headzoo.com>

 * @version $Id: Popup.php 383 2008-07-03 05:31:51Z sean $

 * @package Alinks_Popup

 */

class Alinks_Popup

{

	const KEY_KEYPHRASES	= 'keyphrases';

	const KEY_SETTINGS		= 'settings';

	const KEY_IMPORT_EXPORT	= 'import_export';

	const KEY_FACTORIES		= 'factories';

	const KEY_HELP			= 'help';

	

	/**

	 * Shows a pop-up message

	 *

	 * Shows the helpful message to the user that's tied to the supplied

	 * key. If the user has elected to not see that pop-up again, then

	 * this method will return null.

	 *

	 * @param string $key The pop-up key

	 * @return string|null

	 */

	public static function show($key)

	{

		if (isset($_POST['alinks_hide_popup'])) {

			Alinks_Settings::set('alinks', 'popup_hidden_' . $key, 1);

			return null;

		}

		if (Alinks_Settings::get('alinks', 'popup_hidden_' . $key)) {

			return null;

		}

		

		?>

		<div class="alinks_popup">

			<h3>Tip:</h3>

			<?php

			switch($key) {

				case self::KEY_KEYPHRASES:

					self::showKeyphrases();

					break;

				case self::KEY_SETTINGS:

					self::showSettings();

					break;

				case self::KEY_IMPORT_EXPORT:

					self::showImportExport();

					break;

				case self::KEY_FACTORIES:

					self::showFactories();

					break;

				case self::KEY_HELP:

					self::showHelp();

					break;

			}

			?>

			<form method="post" name="alinks_popup_form">

				<label for="alinks_hide_popup">

					<input type="checkbox" id="alinks_hide_popup" name="alinks_hide_popup" value="<?php echo $key; ?>" onchange="document.alinks_popup_form.submit()"/>

					Never show this again

				</label>

			</form>

		</div>

		<?php

	}

	

	/**

	 * Shows the help text for the keyphrases menu

	 */

	public static function showKeyphrases()

	{

		?>

		<p>This is the keyphrases menu. From this menu you can manage (edit, delete, add) your keyphrases.</p>

		<p>Above the grid you can see three groups of controls. The first lets you add a new keyphrase. The second lets

		you filter the keyphrases in the grid. The last lets you delete and export keyphrases.</p>

		<p>Double-click a row in the grid to edit the keyphrase. To delete keyphrases, check the keyphrases you want to delete,

		and then click the delete icon.</p>

		<p>Refer to the <a href="admin.php?page=alinks_help">documentation</a> for more assistance.</p>

		<?php

	}

	

	/**

	 * Shows the help text for the settings menu

	 */

	public static function showSettings()

	{

		?>

		<p>This is the settings menu. From this menu you can set the options that control the behavior of aLinks, and change the settings

		for the installed factories. You can also uninstall aLinks from the bottom of this menu.</p>

		<p>The aLinks settings are at the top of this page, and the factory settings are below that. Some factories don't have any

		settings.</p>

		<p>Refer to the <a href="admin.php?page=alinks_help">documentation</a> for more assistance.</p>

		<?php

	}

	

	/**

	 * Shows the help text for the import/export menu

	 */

	public static function showImportExport()

	{

		?>

		<p>This is the import/export menu. You can backup your keyphrases (and settings) from the export part of the menu. Then later on use

		the import part of the menu to put them back into the database.</p>

		<p>The aLinks 2.0 XML is the only format that can be exported and imported. The other export formats are provided as a convenience for

		those who need their defined keyphrases for other business purposes.</p>

		<p>Refer to the <a href="admin.php?page=alinks_help">documentation</a> for more assistance.</p>

		<?php

	}

	

	/**

	 * Shows the help text for the factories menu

	 */

	public static function showFactories()

	{

		?>

		<p>This is the factories menu. From this menu you can install and uninstall factories.</p>

		<p>Refer to the <a href="admin.php?page=alinks_help">documentation</a> for more assistance.</p>

		<?php

	}

	

	/**

	 * Shows the help text for the help menu

	 */

	public static function showHelp()

	{

		?>

		<p>The help menu shows aLinks related help, and help for those installed factories that provide HTML help.</p>

		<p>If you can't find the answers to your questions here, try the <a href="http://forums.headzoo.com/viewforum.php?f=5&sid=ff5bda3f9b278e160e41eaffd7f0e295">aLinks forums</a>.</p>

		<?php

	}

}

